package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main3Activity extends AppCompatActivity {

    private ListView lvMain3First;
    private SimpleAdapter adapter;

    private String[] name = {"剑萧舞蝶", "张三", "hello", "诗情画意", "牛说"};

    private String[] desc = {"魔域玩家", "百家执行", "高级的富一代", "妹子请过来..一个善于跑妹子的。", "你是牛吗"};

    private int[] imag = {R.mipmap.ic_launcher, R.mipmap.ic_launcher_round,
            R.mipmap.ic_launcher_beauty, R.mipmap.ic_launcher, R.mipmap.ic_launcher_beauty};

    @Override


    protected void onCreate(Bundle saveInstanceState) {
        super.onCreate(saveInstanceState);
        setContentView(R.layout.activity_main3);
        lvMain3First = (ListView) findViewById(R.id.lv_main3_first);
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main3);
//        lvMain3First = (ListView) findViewById(R.id.lv_main3_first);
//
//        List<Map<String, Object>> mData = new ArrayList<>();
//        for (int i = 0; i <name.length ; i++) {
//            Map<String,Object> map = new HashMap<>();
//            map.put("img",imageids[i]);
//            map.put("text1",name[i]);
//            map.put("text2",desc[i]);
//            mData.add(map);
//        }
//        for (int i = 0; i < name.length; i++) {
//            Map<String, Object> map = new HashMap<>();
//            map.put("img", imageids[i]);
//            map.put("text1", name[i]);
//            map.put("text2", desc[i]);
//            mData.add(map);
//        }
        List<Map<String, Object>> mData1 = new ArrayList<>();

        for (int i = 0; i < name.length; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("ima", imag[i]);
            map.put("name", name[i]);
            map.put("desc", desc[i]);
            mData1.add(map);

        }

//        String[] from = {"img", "text1", "text2"};
//        int[] to = {R.id.iv_main3_first, R.id.tv_main3_first, R.id.tv_main3_second};
//        adapter = new SimpleAdapter(this, mData, R.layout.item_animals, from, to);
        String[] from = {"ima", "name", "desc"};
        int[] to = {R.id.iv_main3_first, R.id.tv_main3_first, R.id.tv_main3_second};

//        lvMain3First.setAdapter(adapter);
        adapter = new SimpleAdapter(this, mData1, R.layout.item_animals, from, to);
        lvMain3First.setAdapter(adapter);
    }
}
